package com.heima.admin.controller_v1;

import com.heima.admin.service.AdUserService;
import com.heima.apis.admin.LoginControllerApi;
import com.heima.model.admin.pojos.AdUser;
import com.heima.model.common.dtos.AdUserDto;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.lang.reflect.InvocationTargetException;

@RestController
@RequestMapping("/login")
public class LoginController implements LoginControllerApi {

    @Resource
    private AdUserService adUserService;

    @Override
    @PostMapping("/register")
    public ResponseResult register(@RequestBody AdUser adUser) {
        return adUserService.register(adUser);
    }

    @Override
    @PostMapping("/in")
    public ResponseResult login(@RequestBody AdUserDto dto) {
        return adUserService.login(dto);
    }
}
